<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Microsoft SQL Server Functions (PDO_SQLSRV)</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-mysql.connection.html">PDO_MYSQL DSN</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.pdo-sqlsrv.connection.html">PDO_SQLSRV DSN</a></div>
 <div class="up"><a href="pdo.drivers.html">PDO 驱动</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ref.pdo-sqlsrv" class="reference">
  <h1 class="title">Microsoft SQL Server Functions (PDO_SQLSRV)</h1>
  
  <div class="partintro">

   <div class="section" id="pdo-sqlsrv.intro">
   <h2 class="title">简介</h2>
    <p class="para">
     PDO_SQLSRV is a driver that implements the <a href="intro.pdo.html" class="link">PHP
     Data Objects (PDO) interface</a>
     to enable access from PHP to MS SQL Server (starting with SQL Server 2005) 
     and SQL Azure databases.
    </p>
   </div>
   

<div class="section" id="ref.pdo-sqlsrv.installation">
 <h2 class="title">安装</h2>
 <p class="para">
  The PDO_SQLSRV extension is enabled by adding appropriate DLL file to your PHP 
  extension directory and the corresponding entry to the <var class="filename">php.ini</var> file. The 
  PDO_SQLSRV download comes 8 driver files, four of which are for PDO support. 
  If you are running non-thread-safe PHP (PHP 5.3), use the php_pdo_sqlsrv_53_nts.dll 
  file. (You should use a non-thread-safe version if you are using IIS as your 
  web server). If you are running thread-safe PHP, use the php_pdo_sqlsrv_53_ts.dll 
  file. Similarly for PHP 5.4, use the php_pdo_sqlsrv_54_nts.dll or php_pdo_sqlsrv_54_ts.dll
  depending on whether your PHP installation is non-thread-safe or thread-safe. 
 </p>
 <p class="para">
  The most recent version of the driver is available for download here:
  <a href="http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx" class="link external">&raquo;&nbsp;SQLSRV 3.0 download</a>. If you need support 
  for PHP 5.2 and/or PHP compiled with VC6, use the 2.0 release of the driver: 
  <a href="http://download.microsoft.com/download/C/D/B/CDB0A3BB-600E-42ED-8D5E-E4630C905371/SQLSRV20.EXE" class="link external">&raquo;&nbsp;SQLSRV 2.0 download</a>.
 </p>
 <p class="para">
  For more information about system requirements, see 
  <a href="http://msdn.microsoft.com/en-us/library/cc296170.aspx" class="link external">&raquo;&nbsp;SQLSRV System Requirements</a>.
 </p>
 <p class="para">
  The PDO_SQLSRV extension is only compatible with PHP running on Windows.
  For Linux, see <a href="ref.pdo-odbc.html" class="link">ODBC</a> and
  <a href="http://www.microsoft.com/download/en/details.aspx?id=28160" class="link external">&raquo;&nbsp;Microsoft&#039;s SQL Server ODBC Driver for Linux</a>.
 </p>
</div>



   

<div class="section" id="pdo-sqlsrv.constants">
 <h2 class="title">预定义常量</h2>
 <p class="simpara">下列常量由此驱动定义，且仅在扩展编译入 PHP
或在运行时动态载入时可用。另外，使用此驱动时，仅会使用这些驱动特定的常量。使用其他驱动的驱动特定的常量可能会导致不可预见的情况。如果代码可运行于多个驱动，<span class="function"><a href="pdo.getattribute.html" class="function">PDO::getAttribute()</a></span>
可被用于获取
<strong><code>PDO_ATTR_DRIVER_NAME</code></strong>
属性以检查驱动。</p>
 <dl>

  
   <dt id="pdo.constants.sqlsrv-txn-read-uncommitted">
    <strong><code>PDO::SQLSRV_TXN_READ_UNCOMMITTED</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Read Uncommitted.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-read-committed">
    <strong><code>PDO::SQLSRV_TXN_READ_COMMITTED</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Read Committed.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-repeatable-read">
    <strong><code>PDO::SQLSRV_TXN_REPEATABLE_READ</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Repeateable Read.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-snapshot">
    <strong><code>PDO::SQLSRV_TXN_SNAPSHOT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to Snapshot.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-serializable">
    <strong><code>PDO::SQLSRV_TXN_SERIALIZABLE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Serializable.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-binary">
    <strong><code>PDO::SQLSRV_ENCODING_BINARY</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved as a raw byte stream to/from the server 
     without performing encoding or translation. This constant can be passed to 
     PDOStatement::setAttribute, PDO::prepare, PDOStatement::bindColumn, and 
     PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-system">
    <strong><code>PDO::SQLSRV_ENCODING_SYSTEM</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server as 8-bit characters 
     as specified in the code page of the Windows locale that is set on the system. 
     Any multi-byte characters or characters that do not map into this code page 
     are substituted with a single byte question mark (?) character. This constant 
     can be passed to PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-utf8">
    <strong><code>PDO::SQLSRV_ENCODING_UTF8</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server in UTF-8 encoding. 
     This is the default encoding. This constant can be passed to 
     PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-default">
    <strong><code>PDO::SQLSRV_ENCODING_DEFAULT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server according to 
     PDO::SQLSRV_ENCODING_SYSTEM if specified during connection. The connection&#039;s 
     encoding is used if specified in a prepare statement. This constant can be 
     passed to PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-attr-query-timeout">
    <strong><code>PDO::SQLSRV_ATTR_QUERY_TIMEOUT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     A non-negative integer representing the timeout period, in seconds. Zero (0) 
     is the default and means no timeout. This constant can be passed to 
     PDOStatement::setAttribute, PDO::setAttribute, and PDO::prepare.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-attr-direct-query">
    <strong><code>PDO::SQLSRV_ATTR_DIRECT_QUERY</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Indicates that a query should be executed directly, without being prepared. 
     This constant can be passed to PDO::setAttribute, and PDO::prepare. For more 
     information, see 
     <a href="http://msdn.microsoft.com/en-us/library/ff754356.aspx" class="link external">&raquo;&nbsp;Direct and Prepared Statement Execution</a>.
    </span>
   </dd>

  
 </dl>

</div>



  </div>

  

 <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-sqlsrv.connection.html">PDO_SQLSRV DSN</a> — Connecting to MS SQL Server and SQL Azure databases</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-mysql.connection.html">PDO_MYSQL DSN</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.pdo-sqlsrv.connection.html">PDO_SQLSRV DSN</a></div>
 <div class="up"><a href="pdo.drivers.html">PDO 驱动</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
